package com.threeti.jiayusms.interfaces.ws.communicationtime;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.CommunicationTime;
import com.threeti.jiayusms.domain.service.communicationtime.CommunicationTimeQueryService;
import com.threeti.jiayusms.interfaces.ws.communicationfunction.CommunicationFunctionDto;

@WebService(serviceName = "TimeTemplateService", portName = "TimeTemplateServicePort", 
		endpointInterface = "com.threeti.jiayusms.interfaces.ws.communicationtime.TimeTemplateWebService", 
		targetNamespace = "http://127.0.0.1:8080/sms-maintenance-main" )
@Transactional
public class TimeTemplateWebServiceDelegate implements TimeTemplateWebService {

	@Autowired
	private CommunicationTimeQueryService queryService;

	@Override
	public CommunicationTimeDto findCommunicationTimeBy(String timeId) {
		CommunicationTime timeTemplate = queryService
				.findCommunicationTimeBy(timeId);

		if(timeTemplate == null){
			return null;
		}
		
		CommunicationTimeDto dto = new CommunicationTimeDto(
				timeTemplate.getAvailDate(),
				timeTemplate.getWorkFlag(),
				timeTemplate.getTimeContent(),
				timeTemplate.getTimeSegment(),
				timeTemplate.getActiveFlag(),
				timeTemplate.getTimeDescription());

		return dto;
	}
	
	@Override
	public List<CommunicationTimeDto> findCommunicationTimeByList(){
		List<CommunicationTimeDto> dto = new ArrayList<CommunicationTimeDto>();
		
		return dto;
	}

}
